home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / turbcomm.arc / CHECKESC.INC next >
Text File  |  1989-06-30  |  4KB  |  109 lines

  1.    { File: CHECKESC.INC }
  2.  
  3.  
  4.    { Definitions for checking out escape sequences, and responding }
  5.    Const
  6.       NumberOfEscapeSequences = 10;
  7.  
  8.    Var
  9.       EscapeSeq : ARRAY [1..NumberOfEscapeSequences] OF STRING[6];
  10.  
  11.  
  12.    Procedure InitEscSeq;
  13.       { Initialize values of escape sequences to check for in CheckEscSeq }
  14.       Begin
  15.          EscapeSeq[1] := 'c';        { Terminal Reset (This would reset RB) }
  16.          EscapeSeq[1][0] := Chr(1);  { Don't count on auto length init. }
  17.          EscapeSeq[2] := '=';        { Keypad Application Mode }
  18.          EscapeSeq[2][0] := Chr(1);
  19.          EscapeSeq[3] := '>';        { Keypad Numeric Mode }
  20.          EscapeSeq[3][0] := Chr(1);
  21.          EscapeSeq[4] := 'Z';        { Terminal ID Request }
  22.          EscapeSeq[4][0] := Chr(1);
  23.          EscapeSeq[5] := '[Z';       { "" }
  24.          EscapeSeq[5][0] := Chr(2);
  25.          EscapeSeq[6] := '[c';       { "" }
  26.          EscapeSeq[6][0] := Chr(2);
  27.          EscapeSeq[7] := '[0c';      { "" }
  28.          EscapeSeq[7][0] := Chr(3);
  29.          EscapeSeq[8] := '[5i';      { Print Controller on }
  30.          EscapeSeq[8][0] := Chr(3);
  31.          EscapeSeq[9] := '[4i';      { Print Controller off }
  32.          EscapeSeq[9][0] := Chr(3);
  33.          EscapeSeq[10] := '[?15n';   { Check Printer Status }
  34.          EscapeSeq[10][0] := Chr(5);
  35.          end;
  36.  
  37.    Procedure CheckEscSeq;
  38.       { Evaluate any escape sequences that come in, and respond
  39.         appropriately }
  40.  
  41.  
  42.       Var
  43.          Counter : Byte;
  44.          PartialMatch, FullMatch : Boolean;
  45.          StoreString : String[6];
  46.  
  47.       Begin
  48.          StoreString[0] := Chr(0);     { Don't count on auto length init. }
  49.  
  50.          Repeat  { Keep getting and checking characters until there's
  51.                    no match with any search strings }
  52.             GetCommChar;           { Get the next character in the esc seq }
  53.             StoreString := StoreString + CommIn.Char;
  54.             Counter := 0;
  55.             PartialMatch := False;
  56.             FullMatch := False;
  57.  
  58.             { Check if StoreString is in list }
  59.             While (Counter < NumberOfEscapeSequences) And
  60.                (Not FullMatch) Do
  61.                Begin
  62.                   Counter := Counter + 1;
  63.                   If Pos(StoreString,EscapeSeq[Counter]) = 1 Then
  64.                      Begin
  65.                         PartialMatch := True;
  66.                         If StoreString = EscapeSeq[Counter] Then
  67.                            FullMatch := True;
  68.                         End { There was at least a partial match }
  69.                   End; { While }
  70.             Until (Not PartialMatch) OR (FullMatch);
  71.  
  72.  
  73.             If Not PartialMatch Then
  74.                   Begin
  75.                      If DisplayOn And Not Printeron
  76.                         Then Write(Esc,StoreString)
  77.                         Else If PrinterOn
  78.                                 Then Write(Lst,Esc,StoreString)
  79.                                 Else Begin
  80.                                    Write(Esc,StoreString);
  81.                                    Write(Lst,Esc,StoreString);
  82.                                    End; { both display and print }
  83.                       If LoggingOn Then Write(FileVar,Esc,StoreString);
  84.                       End;
  85.  
  86.             If FullMatch = True Then
  87.                Case Counter of
  88.                   { Put in the choices and procedures to run here }
  89.                   1:  ; { Ignore terminal reset request }
  90.                   2:  ApplicationKeypadMode; { Chg keys to Appl }
  91.                   3:  NumericKeypadMode;     { Chg keys to Num  }
  92.                   4..7: WriteCommString(TermID); { term ID request }
  93.                   8:  Begin   { Print controller on request }
  94.                          PrinterOn := True;
  95.                          DisplayOn := False;
  96.                          End;
  97.                   9:  Begin   { Print controller off request }
  98.                          PrinterOn := False;
  99.                          DisplayOn := True;
  100.                          End;
  101.                   10: { Printer status request }
  102.                       If CheckPrinter
  103.                          Then WriteCommString(PrinterReady)
  104.                          Else WriteCommString(PrinterNotReady);
  105.                   End; { Case statement }
  106.  
  107.             End; { Procedure CheckEscSeq }
  108.  
  109.